package com.zbb.online_exam.utils;

import java.util.Random;
import java.util.UUID;

/**
 * 随机操作相关的工具类
 */
public class RandomUtils {
    private RandomUtils() {

    }

    /**
     * 用于生成一个随机字符串
     * @param length 字符串的长度
     * @return 生成随机字符串
     */
    public static String getRandomString(int length) {
        Random random = new Random();
        String strs = "3456789abcdefghjkmnpqrstuvwxy";
        String result = "";
        for (int i = 1; i <= length; i++) {
            char character = strs.charAt(random.nextInt(strs.length()));
            result += character;
        }
        return result;
    }

    /**
     * 获取UUID
     * @return UUID
     */
    public static String getUuid() {
        return UUID.randomUUID().toString().replace("-", "");
    }
}
